package com.tm.service.impl;

import com.tm.mapper.BannerMapper;
import com.tm.pojo.vo.BannerVo;
import com.tm.result.Result;
import com.tm.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author xiaobai
 * @create 2022-12-16 20:01
 */
@Service
public class BannerServiceImpl implements BannerService {

    // 轮播图类型
    private static Map<Integer,String> bannerMap = new HashMap();

    static {
        bannerMap.put(1,"文章");
        bannerMap.put(2,"通知");
        bannerMap.put(3,"商品");
    }
    @Autowired
    private BannerMapper bannerMapper;

    //banner轮播图
    public Result carouselBanner() {

       List<BannerVo> bannerVoList =  bannerMapper.carouselBanner();
       bannerVoList.forEach(a->{
            a.setBannerType(bannerMap.get(a.getBannerTypeId()));
       });

        return Result.SUCCESS(bannerVoList);
    }
}
